package com.ttc.ssm.controller.admin;

import com.ttc.ssm.service.admin.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by Jiarui on 2016/7/22.
 */
@Controller
@RequestMapping("/admin/index")
public class IndexController {

    @Autowired
    IndexService indexService;

    @RequestMapping("/index")
    public String index(Model model) throws Exception {
        int company_num = indexService.countCompany();
        model.addAttribute("company_num",company_num);
        int confirm_company_num = indexService.countCompanyDetail(1);
        model.addAttribute("confirm_company_num",confirm_company_num);
        int confirming_company_num = indexService.countCompanyDetail(0);
        model.addAttribute("confirming_company_num",confirming_company_num);
        int customer_num = indexService.count_customer();
        model.addAttribute("customer_num",customer_num);
        int job_num = indexService.countJob();
        model.addAttribute("job_num",job_num);
        int confirmingJob_num = indexService.countConfirmingJob(0);
        model.addAttribute("confirmingJob_num",confirmingJob_num);
        int resume_num = indexService.countResume();
        model.addAttribute("resume_num",resume_num);
        int ad_num = indexService.countAd();
        model.addAttribute("ad_num",ad_num);
        Map map = indexService.countCompanyByMonth();
        model.addAttribute("company_num_list",map.get("y"));
        model.addAttribute("company_x",map.get("x"));
        Map map1 = indexService.countCustomerByMonth();
        model.addAttribute("customer_num_list",map1.get("y"));
        model.addAttribute("customer_x",map1.get("x"));
        return "admin/index/index";
    }

}
